package com.qf.controller;


import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.OutputStream;

@Controller
@RequestMapping("/system/res")
public class ResourceController {

    /**
     * 获取上传图片
     */
    @RequestMapping("/getImage")
    @ResponseBody
    public void getImage(String path, HttpServletResponse response){
        System.out.println("获取图片的上传路径：" + path);
        try(
            InputStream in = new FileInputStream(path);
            OutputStream out = response.getOutputStream();
        ) {
            IOUtils.copy(in, out);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
